package views;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;

public class TurretInterfaceView extends JFrame implements ActionListener {

	private static JButton manualInterfaceButton;
	private static TurretManualControlView manualControlView = null;
	
	private static final JLabel stepperMotorPositionTextLabel = new JLabel("Stepper motor position:");
	public static JLabel stepperMotorPositionLabel;
	private static final JLabel servoPositionTextLabel = new JLabel("Servo position:");
	public static JLabel servoPositionLabel;
	
	public TurretInterfaceView(String title) {
		
		this.setBounds(100, 100, 300, 300);
		this.setResizable(false);
		this.setDefaultCloseOperation(EXIT_ON_CLOSE);
		this.setTitle(title);
		this.setLayout(null);
		
		manualInterfaceButton = new JButton("Manual Control");
		manualInterfaceButton.setBounds(20, 20, 200, 20);
		manualInterfaceButton.addActionListener(this);
		this.add(manualInterfaceButton);
		
		stepperMotorPositionTextLabel.setBounds(20, 50, 150, 20);
		this.add(stepperMotorPositionTextLabel);
		stepperMotorPositionLabel = new JLabel("0");
		stepperMotorPositionLabel.setBounds(160, 50, 100, 20);
		this.add(stepperMotorPositionLabel);
		
		servoPositionTextLabel.setBounds(20, 80, 150, 20);
		this.add(servoPositionTextLabel);
		servoPositionLabel = new JLabel("3456");
		servoPositionLabel.setBounds(160, 80, 100, 20);
		this.add(servoPositionLabel);
		
		this.setVisible(true);
		
	}

	public void actionPerformed(ActionEvent e) {
		if(e.getSource().equals(manualInterfaceButton)) {
			if(manualControlView != null)
				manualControlView.dispose();
			manualControlView = null;
			manualControlView = new TurretManualControlView("Manual Control");
		}
	}
	
}
